<template>
	<view class="my-page">
		<u-navbar leftIconColor="#000" :autoBack="true" :placeholder="true" bgColor="rgba(255,255,255,0.0)">
			<view slot="center" class="nav-title">
				商品币
			</view>
		</u-navbar>
		<view class="head-box">
			<view class="head-top">
				<view class="head-left">
					<view class="head-text">
						商品币
					</view>
					<view class="head-num">
						{{balance}}
					</view>
				</view>
				<view class="head-btn" @click="$router.push('/pages/my/gmc/gift')">
					转增
				</view>
			</view>
			<view class="gold">
				<image src="../../../static/home/gold.png" mode="widthFix"></image>
			</view>
		</view>
		<view v-if="list.length > 0">
			<view class="record-item" v-for="(item,index) in list" :key="index">
				<view class="record-left">
					<view class="record-text">
						{{item.message}}
					</view>
					<view class="record-time">
						{{item.time}}
					</view>
				</view>
				<view class="record-num">
					{{item.num}}
				</view>
			</view>
			<u-loadmore :status="status" />
		</view>
		<view v-else>
			<u-empty mode="car" icon="../../../static/home/none.png" text="暂无数据" marginTop="100">
			</u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				balance: '',
				list: [],
				page: 1,
				status: 'loadmore',
			}
		},
		onLoad() {
			this.getInfo()
		},
		onReachBottom() {
			this.page++
			this.status = 'loading';
			this.getInfo()
		},
		methods: {
			getInfo() {
				let params = {
					page: this.page
				}
				this.$Request({
					method: 'POST',
					url: '/api/mutualaidorder/giveban',
					data: params,
					ismsg: false,
				}).then(res => {
					if (res.code == 1) {
						console.log(res)
						this.balance = res.data.balance
						if (res.data.list.length < 10) {
							this.status = 'nomore';
						}
						if (this.page == 1) {
							this.list = res.data.list
						} else {
							this.list = [...this.list, ...res.data.list]
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.my-page {
		background-image: url('../../../static/home/home-bg.png');
		background-repeat: no-repeat;
		background-size: 100% 500rpx;
		min-height: 80vh;
		padding: 30rpx;

		.nav-title {
			color: #000;
		}

		.head-box {
			background-image: url('../../../static/home/fun-bg.png');
			background-repeat: no-repeat;
			background-size: 100% 100%;
			padding: 30rpx;
			position: relative;
			margin-bottom: 30rpx;
			.gold {
				position: absolute;
				right: 20rpx;
				top: -10rpx;
			
				image {
					width: 180rpx;
					height: 120rpx;
				}
			}

			.head-top {
			
				.head-left {
					color: #fff;
			
					.head-text {
						font-size: 24rpx;
					}
			
					.head-num {
						font-size: 60rpx;
						font-weight: bold;
						margin-top: 10rpx;
					}
				}
			
				.head-btn {
					color: #fff;
					font-size: 26rpx;
					padding: 22rpx;
					background-color: rgba(255, 255, 255, .16);
					border-radius: 10rpx;
					margin-top: 30rpx;
					text-align: center;
				}
			}
		}

		.record-item {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 20rpx 30rpx;
			background-color: #fff;
			border-radius: 20rpx;
			margin-bottom: 20rpx;
			box-shadow: 0rpx 3rpx 32rpx 1rpx rgba(0, 0, 0, 0.08);

			.record-left {
				.record-text {
					font-size: 30rpx;
					color: #333;
				}

				.record-time {
					font-size: 24rpx;
					color: #999999;
					margin-top: 5rpx;
				}
			}

			.record-num {
				font-size: 32rpx;
				color: #333;
				font-weight: bold;
			}

			.add {
				color: #FD5674;
			}
		}
	}
</style>s